package main

// 使用 select 多路复用：如果你需要从多个 channel 中接收消息，你可以使用 select 语句来同时监听它们。
import "fmt"

func main() {
	channel1 := make(chan string)
	channel2 := make(chan string)

	go func() {
		channel1 <- "hello"
		close(channel1)
	}()
	go func() {
		channel2 <- "world"
		close(channel2)
	}()

	for i := 0; i < 2; i++ {
		select {
		case msg := <-channel1:
			fmt.Println(msg)
		case msg := <-channel2:
			fmt.Println(msg)
		}
	}

}
